package com.think.teaching.mapper;

import java.util.Map;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.think.teaching.model.CourseHistory;

public interface CourseHistoryMapper extends BaseMapper<CourseHistory> {
	
	@Select("<script>"
			+ 
			"SELECT h.*,c.course_name,c.type FROM course_history h LEFT JOIN course c ON c.id=h.course_id "
			+
			"<if test='courseId gt 0'>WHERE h.course_id=#{courseId} </if>"
			+ "</script>")
	@Result(column="course_id",property="course_id")
	@Result(column="course_id",property="teacherInfo",javaType = Map.class,one = @One(select = "com.think.teaching.mapper.CourseMemberMapper.GetFirstMember",fetchType = FetchType.EAGER))
	IPage<Map<String, Object>> ListHistorys(IPage<Map<String, Object>> page,@Param("courseId")Integer courseId);
	
	

	

}
